

*** This do file creates stacked event studies dataset minimum wage precommittment paper
*** using the year of the first minimum wage increase as the event date

****************************************************************************************************
************							   1. Set Up Data 	                            ************
****************************************************************************************************

* -------------------------- 1.1 Preamble Commands --------------------------- 

clear all 
set more off 
capture log close 
* If needed change global path to point to directory where files are stored on your computer
*global path "I:/DataSets5/Duncan/Dropbox/Recent Minimum Wage Changes/2020.12 NBER Update/JOLE Precommittment Replication"

global dtadir "$path/Data"
global tabdir "$path/Tables"
global figdir "$path/Figures"
global estdir "$path/Estimates"
global logdir "$path/Logfiles"


log using "$logdir/Generate_Stacked_Event_Study_Dataset.log", replace

*** Assemble relevant years of ACS 
use "${path}/Data/ACS-2019.dta", clear

* Generate Unique ACS Person Level ID
egen acsidp = group(year sample serial pernum)

*** Drop seniors
drop if age >= 65 | age < 16
drop if empstat == 0

*** Construct economic outcomes of interest 
gen employed = 0
replace employed = 1 if  empstat == 1

gen inlaborforce = 0
replace inlaborforce = 1 if  labforce == 2

gen unemployed = 0
replace unemployed = 1 if inlaborforce == 1 & employed == 0

*** Construct education variables
gen dropout = 0 
replace dropout = 1 if educ < 6
gen highschool = 0 
replace highschool = 1 if educ == 6
gen somecollege = 0
replace somecollege = 1 if educ >= 7 & educ < 10
gen collegeplus = 0
replace collegeplus = 1 if educ >= 10

***
* Assign the policy categories
***

merge m:1 statefip using "${path}/Data/min_wage_variables_for_ACS_and_CPS_analysis.dta"
drop _merge

gen indexer = 0
replace indexer = 1 if originaltype == "Indexer"
gen StatIncreaserLarge = 0
replace StatIncreaserLarge = 1 if indexer == 0 & (jan2015min - jan2013min) >= 1 & (jan2016min - jan2013min) != .
gen statutoryincreasein2014or2015 = 0
replace statutoryincreasein2014or2015 = 1 if (jan2016min - jan2013min) > 0 & indexer == 0
gen StatIncreaserSmall = 0
replace StatIncreaserSmall = 1 if indexer == 0 & statutoryincreasein2014or2015 == 1 & StatIncreaserLarge == 0

drop statincreasebydec20*
drop statincreasebyjan20*

*** Merge in HPI and Personal Income controls
merge m:1 statefip year using "${path}/Data/HousingIndexChanges.dta"
keep if _merge == 3
drop _merge
merge m:1 statefip year using "${path}/Data/PersonalIncomeChanges.dta"
keep if _merge == 3
drop _merge


*** Fix weight variable
rename perwt cmpwgt

* Merge January minimum wage data back to 2010
merge m:1 statefip year using "${path}/Data/minimum-wage-yearly.dta"

gen mw_jan =. 

forval year = 2011/2019 {
	replace mw_jan = jan`year'min if year == `year'
}

forval year = 2011/2019 {
	gen mw_jan`year'B = mw_jan if year == `year'
	gegen mw_jan`year' = max(mw_jan`year'B), by(statefip)
	drop mw_jan`year'B
}

forval year = 2012/2019 {
	local j = `year' - 1
	gen mw_change`year' = mw_jan`year' - mw_jan`j' > .01
}

gen totalchange = mw_jan2019 - mw_jan2011


* Generate year of first increase
gen eventyear = 0
replace eventyear = 2012 if mw_change2012 == 1
replace eventyear = 2013 if mw_change2013 == 1 & mw_change2012 == 0
replace eventyear = 2014 if mw_change2014 == 1 & mw_change2012 == 0 & mw_change2013 == 0
replace eventyear = 2015 if mw_change2015 == 1 & mw_change2012 == 0 & mw_change2013 == 0 & mw_change2014 == 0
replace eventyear = 2016 if mw_change2016 == 1 & mw_change2012 == 0 & mw_change2013 == 0 & mw_change2014 == 0 & mw_change2015 == 0
replace eventyear = 2017 if mw_change2017 == 1 & mw_change2012 == 0 & mw_change2013 == 0 & mw_change2014 == 0 & mw_change2015 == 0 & mw_change2016 == 0 
replace eventyear = 2018 if mw_change2018 == 1 & mw_change2012 == 0 & mw_change2013 == 0 & mw_change2014 == 0 & mw_change2015 == 0 & mw_change2016 == 0 & mw_change2017 == 0
replace eventyear = 2019 if mw_change2019 == 1 & mw_change2012 == 0 & mw_change2013 == 0 & mw_change2014 == 0 & mw_change2015 == 0 & mw_change2016 == 0 & mw_change2017 == 0 & mw_change2018 == 0
drop mw_change2012 mw_change2013 mw_change2014 mw_change2015 mw_change2016 mw_change2017  mw_change2018 mw_change2019

* Since New York's increase officially occurs on 12/31/2013 just set the year of first increase and year of first legislated increase to 2014
replace eventyear = 2014 if statefip == 36

* Generate time to first increase
gen inctime = year + 1 - eventyear
replace inctime = 999 if inctime > 2010

*** Create event dummies for all statutory increasers equal to 1 on the year of first increase
gen inctimeneg4plus = inctime <= -4
gen inctimeneg3plus = inctime <= -3
gen inctimeneg2plus = inctime <= -2
gen inctimeneg3 = inctime == -3
gen inctimeneg2 = inctime == -2
gen inctimeneg1 = inctime == -1
gen inctimezero = inctime == 0
gen inctimepos1 = inctime == 1
gen inctimepos2 = inctime == 2
gen inctimepos3 = inctime == 3
gen inctimepos2plus = inctime >= 2 & inctime != 999
gen inctimepos3plus = inctime >= 3 & inctime != 999
gen inctimepos4plus = inctime >= 4 & inctime != 999

*** Generate year of First Increase or First Legislated Increase
gen year1 = year(date1)
gen legyear1 = year(legdate1)

*** Drop states that are only indexers and never changed to increasers at any point (Florida, Montana, and Ohio)
drop if statefip == 12 | statefip == 30 | statefip == 39

*** Alter event years for states that have either always been indexers or that shifted
*** from being indexers to having new statory increases.
gen eventyearNOI = eventyear
replace eventyearNOI = 0 if statefip == 12 | statefip == 30 | statefip == 39
replace eventyearNOI = 2014 if statefip == 50 | statefip == 36
replace eventyearNOI = 2016 if statefip == 41
replace eventyearNOI = 2017 if statefip == 4 | statefip == 8 |  statefip == 23 | statefip == 53
replace eventyearNOI = 2019 if statefip == 29

gen inctimeNOI = year + 1 - eventyearNOI
replace inctimeNOI = 999 if inctimeNOI > 2010

*** Create event dummies for all statutory increasers equal to 1 on the year of first increase
gen inctimeNOIneg4plus = inctimeNOI <= -4
gen inctimeNOIneg3plus = inctimeNOI <= -3
gen inctimeNOIneg2plus = inctimeNOI <= -2
gen inctimeNOIneg3 = inctimeNOI == -3
gen inctimeNOIneg2 = inctimeNOI == -2
gen inctimeNOIneg1 = inctimeNOI == -1
gen inctimeNOIzero = inctimeNOI == 0
gen inctimeNOIpos1 = inctimeNOI == 1
gen inctimeNOIpos2 = inctimeNOI == 2
gen inctimeNOIpos3 = inctimeNOI == 3
gen inctimeNOIpos2plus = inctimeNOI >= 2 & inctimeNOI != 999
gen inctimeNOIpos3plus = inctimeNOI >= 3 & inctimeNOI != 999
gen inctimeNOIpos4plus = inctimeNOI >= 4 & inctimeNOI != 999

* Since we don't have 2020 data yet, put the states with first increases in 2020 or first legislation passed in 2019 into the never increased category
replace year1 =. if year1 == 2020
replace legyear1 =. if legyear1 == 2019

tab year1
tab legyear1

* First increase associated with new legislation
* For most states, this will be the year after a minimum wage increase is passed
* But some states, like DE, MI, MN, and OR passed and enacted an increase in the same calendar year.
gen legimpyear1 = legyear1

replace legimpyear1 = legyear1 + 1 if legyear1 !=. & !inlist(statefip,10,26,27,41)

replace legimpyear1 = legyear1 if inlist(statefip,10,26,27,41)

* Get cohorts for each increase type
levelsof year1, local(firstincreaseyear)
levelsof legyear1, local(firstlegyear)
levelsof legimpyear1, local(legimpyear)

keep employed legimpyear1 legyear1 year1 statefip year age dropout cmpwgt *HPI *lnPersonalIncome educ StatIncreaserSmall StatIncreaserLarge indexer acsidp effectiveminwage gq
compress

save "${path}/Data/ACSEventStudiesData.dta", replace